
package IGU;
import Comun.SamiFrame;
import javax.swing.SwingWorker;
import org.edisoncor.gui.util.WindowDragger;

public class Pantallas extends SamiFrame
{
private static Pantallas yo=null;
    private String[] TiposDatos={"Texto","Texto","Texto","Boleano"};
    private Pantallas() {
        initComponents();
         String osnom=System.getProperty("os.name");
        if( !osnom.equals("Mac OS X")){ 
            this.jMenuBar1.setVisible(false);
             new WindowDragger(this,this.pnl_Cerrar1);
        }
        colapsablePlus1.setPadre(this);  
        this.pnlFiltro1.setVisible(false);
        this.pack();
        this.tablaFuente1.setTiposDatos(TiposDatos);
        Refrescar();
        this.pnl_Cerrar1.setPapa(this);  
    }
    
    public static Pantallas getInstance(){
        if(getYo()==null) setYo(new Pantallas()); 
        
        return getYo();
    }
    
    
    @Override
    public  boolean Refrescar(){
            
        final SwingWorker worker = new SwingWorker(){
            @Override
            protected Object doInBackground()  {
                try{
                  
                getGlassPane().setVisible(true);
                jProgressBar1.setValue(1);
                jProgressBar1.setString("Cargando Datos....");
                fuenteTabla1.Siguiente();
                jProgressBar1.setValue(33);
                jProgressBar1.setString("Actualizando Tabla....");
                fuenteTabla2.Consultar();
                pnlRegistro2.isTodoOK();
                int i = 0; 
                tablaFuente1.getColumnModel().getColumn(i).setWidth(80);
                tablaFuente1.getColumnModel().getColumn(i).setMaxWidth(100);
                tablaFuente1.getColumnModel().getColumn(i).setMinWidth(60);
                i=1; 
                jProgressBar1.setValue(50);
                jProgressBar1.setString("Ajustando Tabla....");
                tablaFuente1.getColumnModel().getColumn(i).setWidth(100);
                tablaFuente1.getColumnModel().getColumn(i).setMinWidth(80);
                i=2; 
                jProgressBar1.setValue(66);
                jProgressBar1.setString("Creando Menus....");
                tablaFuente1.getColumnModel().getColumn(i).setWidth(80);
                tablaFuente1.getColumnModel().getColumn(i).setMinWidth(60);
                tablaFuente1.getColumnModel().getColumn(i).setMaxWidth(120);
                pnlFiltro1.lblcampo1.setText("Pais");
                pnlFiltro1.lblCampo2.setText("Nombre");
                jProgressBar1.setString("Finalizando....");
                jProgressBar1.setValue(100);
                getGlassPane().setVisible(false);
                jProgressBar1.setValue(0);
                jProgressBar1.setString("Listo....");
                }catch(Exception ex){
                    jProgressBar1.setIndeterminate(true);
                    jProgressBar1.setString("Error de Carga....");
                }
                return null;
            }
                
        };
  
        worker.execute();
    return true;
    }
   @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        fuenteConexion1 = new Controlador.Controladores.FuenteConexion();
        fuenteTabla1 = new Controlador.Controladores.FuenteTabla();
        fuenteTabla2 = new Controlador.Controladores.FuenteTabla();
        panelRoundTranslucido1 = new Comun.PanelRoundTranslucido();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        labelObjetivo1 = new Comun.LabelObjetivo();
        textFieldFuente1 = new Controlador.Componentes.TextFieldFuente();
        textFieldFuente2 = new Controlador.Componentes.TextFieldFuente();
        chekBoxFuente1 = new Controlador.Componentes.ChekBoxFuente();
        textFieldFuente3 = new Controlador.Componentes.TextFieldFuente();
        jLabel3 = new javax.swing.JLabel();
        pnl_Cerrar1 = new Comun.Pnl_Cerrar();
        pnlNavegacion1 = new Comun.pnlNavegacion();
        pnlRegistro2 = new Comun.pnlRegistro();
        pnlFiltro1 = new Comun.pnlFiltro();
        colapsablePlus1 = new Comun.ColapsablePlus();
        panelRoundTranslucido2 = new Comun.PanelRoundTranslucido();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaFuente1 = new Controlador.ComponentesCompuestos.TablaFuente();
        jProgressBar1 = new javax.swing.JProgressBar();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenu3 = new javax.swing.JMenu();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem3 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem4 = new javax.swing.JCheckBoxMenuItem();

        fuenteConexion1.setBaseDatos("u164902_sami");
        fuenteConexion1.setIp("sw-sami.com:3306");
        fuenteConexion1.setPassword("#19$09LGSP-1a");
        fuenteConexion1.setUsuario("u164902_sami");

        fuenteTabla1.setFc(fuenteConexion1);
        fuenteTabla1.setSqlcode("select * from tbl_pantallas;");

        fuenteTabla2.setFc(fuenteConexion1);
        fuenteTabla2.setSqlcode("select Id_pantalla as \"Pantalla\", Nombre as \"Nombre\", Descripcion as \"Descripción\", Estado as \"Estado\" from tbl_pantallas;");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Catálogo de Paises");

        panelRoundTranslucido1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 14));
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Clave de la Pantalla");
        panelRoundTranslucido1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1));

        jLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 14));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Nombre");
        panelRoundTranslucido1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 20, -1, -1));

        labelObjetivo1.setForeground(new java.awt.Color(204, 204, 204));
        labelObjetivo1.setText(" ");
        labelObjetivo1.setFont(new java.awt.Font("Lucida Grande", 3, 14));
        panelRoundTranslucido1.add(labelObjetivo1, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 150, 440, -1));

        textFieldFuente1.setCampo("Id_pantalla");
        textFieldFuente1.setExtremos(new int[] {5, 40});
        textFieldFuente1.setLlave(true);
        textFieldFuente1.setObjetivo(labelObjetivo1);
        textFieldFuente1.setTbl(fuenteTabla1);
        textFieldFuente1.setValidacionExp(2);
        textFieldFuente1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFieldFuente1ActionPerformed(evt);
            }
        });
        panelRoundTranslucido1.add(textFieldFuente1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 45, 191, -1));
        textFieldFuente1.getAccessibleContext().setAccessibleParent(this);

        textFieldFuente2.setCampo("Nombre");
        textFieldFuente2.setObjetivo(labelObjetivo1);
        textFieldFuente2.setTbl(fuenteTabla1);
        textFieldFuente2.setValidacionExp(2);
        panelRoundTranslucido1.add(textFieldFuente2, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 45, 250, -1));

        chekBoxFuente1.setForeground(new java.awt.Color(255, 255, 255));
        chekBoxFuente1.setText("Estatus");
        chekBoxFuente1.setCampo("Estatus");
        chekBoxFuente1.setFont(new java.awt.Font("Lucida Grande", 0, 14));
        chekBoxFuente1.setTbl(fuenteTabla1);
        chekBoxFuente1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                chekBoxFuente1MouseClicked(evt);
            }
        });
        panelRoundTranslucido1.add(chekBoxFuente1, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 50, -1, -1));

        textFieldFuente3.setCampo("Descripcion");
        textFieldFuente3.setExtremos(new int[] {5, 95});
        textFieldFuente3.setObjetivo(labelObjetivo1);
        textFieldFuente3.setTbl(fuenteTabla1);
        textFieldFuente3.setValidacionExp(2);
        panelRoundTranslucido1.add(textFieldFuente3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 106, 630, -1));

        jLabel3.setFont(new java.awt.Font("Lucida Grande", 0, 14));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Descripción");
        panelRoundTranslucido1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 81, -1, -1));

        pnlNavegacion1.setFT(fuenteTabla1);

        pnlRegistro2.setFT(fuenteTabla1);
        pnlRegistro2.setEditor(panelRoundTranslucido1);
        pnlRegistro2.setFiltro(pnlFiltro1);
        pnlRegistro2.setNav(pnlNavegacion1);
        pnlRegistro2.setParent(this);
        pnlRegistro2.setTabla("tbl_pais");

        pnlFiltro1.setFt(fuenteTabla2);
        pnlFiltro1.setHijo(panelRoundTranslucido1);

        colapsablePlus1.setCambios(pnlRegistro2);
        colapsablePlus1.setEditor(panelRoundTranslucido1);
        colapsablePlus1.setMov(pnlNavegacion1);
        colapsablePlus1.setTabla(panelRoundTranslucido2);

        tablaFuente1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tablaFuente1.setData(fuenteTabla2);
        jScrollPane1.setViewportView(tablaFuente1);

        jProgressBar1.setStringPainted(true);

        org.jdesktop.layout.GroupLayout panelRoundTranslucido2Layout = new org.jdesktop.layout.GroupLayout(panelRoundTranslucido2);
        panelRoundTranslucido2.setLayout(panelRoundTranslucido2Layout);
        panelRoundTranslucido2Layout.setHorizontalGroup(
            panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                .addContainerGap()
                .add(panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(panelRoundTranslucido2Layout.createSequentialGroup()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 653, Short.MAX_VALUE)
                        .addContainerGap())
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, panelRoundTranslucido2Layout.createSequentialGroup()
                        .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 191, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(30, 30, 30))))
        );
        panelRoundTranslucido2Layout.setVerticalGroup(
            panelRoundTranslucido2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 172, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE)
                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jMenu1.setText("Archivo");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Registro");
        jMenuBar1.add(jMenu2);

        jMenu3.setText("Ver");

        jCheckBoxMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        jCheckBoxMenuItem1.setSelected(true);
        jCheckBoxMenuItem1.setText("Editor");
        jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItem1ActionPerformed(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem1);

        jCheckBoxMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        jCheckBoxMenuItem2.setSelected(true);
        jCheckBoxMenuItem2.setText("Tabla");
        jCheckBoxMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem2);

        jCheckBoxMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        jCheckBoxMenuItem3.setSelected(true);
        jCheckBoxMenuItem3.setText("Barra de Desplazamiento");
        jCheckBoxMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItem3ActionPerformed(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem3);

        jCheckBoxMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        jCheckBoxMenuItem4.setSelected(true);
        jCheckBoxMenuItem4.setText("Panel de Cambios");
        jCheckBoxMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxMenuItem4ActionPerformed(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem4);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                .add(layout.createSequentialGroup()
                    .add(pnlNavegacion1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 170, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(pnlRegistro2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 220, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(org.jdesktop.layout.GroupLayout.LEADING, pnlFiltro1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(org.jdesktop.layout.GroupLayout.LEADING, panelRoundTranslucido1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(org.jdesktop.layout.GroupLayout.LEADING, panelRoundTranslucido2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(org.jdesktop.layout.GroupLayout.LEADING, colapsablePlus1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 550, Short.MAX_VALUE))
            .add(pnl_Cerrar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 693, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(pnl_Cerrar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(colapsablePlus1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panelRoundTranslucido2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(panelRoundTranslucido1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 180, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(10, 10, 10)
                .add(pnlFiltro1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 150, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(pnlNavegacion1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(pnlRegistro2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void chekBoxFuente1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_chekBoxFuente1MouseClicked
        repaint();
    }//GEN-LAST:event_chekBoxFuente1MouseClicked

    private void pnlFiltro1ComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_pnlFiltro1ComponentShown
        this.pack();
    }//GEN-LAST:event_pnlFiltro1ComponentShown

    private void textFieldFuente1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFieldFuente1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textFieldFuente1ActionPerformed

    private void jCheckBoxMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed
        this.colapsablePlus1.accion(1);
    }//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed

    private void jCheckBoxMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem2ActionPerformed
       this.colapsablePlus1.accion(2);
    }//GEN-LAST:event_jCheckBoxMenuItem2ActionPerformed

    private void jCheckBoxMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem3ActionPerformed
        this.colapsablePlus1.accion(3);
    }//GEN-LAST:event_jCheckBoxMenuItem3ActionPerformed

    private void jCheckBoxMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem4ActionPerformed
      this.colapsablePlus1.accion(4);
    }//GEN-LAST:event_jCheckBoxMenuItem4ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new Pantallas().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private Controlador.Componentes.ChekBoxFuente chekBoxFuente1;
    private Comun.ColapsablePlus colapsablePlus1;
    private Controlador.Controladores.FuenteConexion fuenteConexion1;
    private Controlador.Controladores.FuenteTabla fuenteTabla1;
    private Controlador.Controladores.FuenteTabla fuenteTabla2;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem3;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private Comun.LabelObjetivo labelObjetivo1;
    private Comun.PanelRoundTranslucido panelRoundTranslucido1;
    private Comun.PanelRoundTranslucido panelRoundTranslucido2;
    private Comun.pnlFiltro pnlFiltro1;
    private Comun.pnlNavegacion pnlNavegacion1;
    private Comun.pnlRegistro pnlRegistro2;
    private Comun.Pnl_Cerrar pnl_Cerrar1;
    private Controlador.ComponentesCompuestos.TablaFuente tablaFuente1;
    private Controlador.Componentes.TextFieldFuente textFieldFuente1;
    private Controlador.Componentes.TextFieldFuente textFieldFuente2;
    private Controlador.Componentes.TextFieldFuente textFieldFuente3;
    // End of variables declaration//GEN-END:variables
    /**
     * @return the yo
     */
    public static Pantallas getYo() {
        return yo;
    }

    /**
     * @param aYo the yo to set
     */
    public static void setYo(Pantallas aYo) {
        yo = aYo;
    }



}
